package Reflect;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class ReflectDemo5 {
    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        Class cls = Class.forName("Reflect.Person");
        Object obj = cls.newInstance();

        Method method1 = cls.getMethod("say", String.class);
        method1.invoke(obj,"haha");

        Method method2 = cls.getMethod("say", String.class,int.class);
        method2.invoke(obj,"hehe",100);
    }
}
